<?php
 /***************************************************************
 * Mor-MVC Framework, A framework that can easily let you build a powerful
 * and scalable web application based on PHP language,
 * this framewrok is a copy of the Zend Behavior Framework
 *  Copyright (C) 2010  Nabil Droussi <nabildroussi@gmail.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***************************************************************/
define('CONFIG_LANGUAGE_FILE_INCLUDED',true);
class LocalLanguage
{
	static function getErrorMessage($message,$lang = 'en_US')
	{
		$langsDirectory = dirname(__FILE__);
		$langFile = $langsDirectory."/languages/{$lang}.xml";
		if(!file_exists($langsDirectory."/languages/{$lang}.xml"))
			throw new Exception("Cannot find the language xml file.");
		$xml = simplexml_load_file($langFile);
		foreach($xml->messages->message as $msg)
		{
			if($msg->key == $message)
			{
				return $msg->value;
			}
		}
		return null;
	}
}
?>